import {
  SearchOutlined,
  BellOutlined,
  AppstoreOutlined,
  UnorderedListOutlined,
  // BlockOutlined,
  // AppstoreAddOutlined,
  PictureOutlined,
  CameraOutlined,
  VideoCameraOutlined,
  FontSizeOutlined,
  BgColorsOutlined,
  LayoutOutlined,
  ShoppingCartOutlined,
  TagOutlined,
  StarOutlined,
  FireOutlined,
} from '@ant-design/icons'
import React from 'react'

export type ComponentItem = {
  id: number
  icon: React.ComponentType
  text: string
  type: string // 添加type属性
}

export type CategoryConfig = {
  key: string
  label: string
  items: ComponentItem[]
}

let nextId = 1

/**
 * 动态添加id
 * @param items
 */
const addIdsToItems = (items: Omit<ComponentItem, 'id'>[]): ComponentItem[] => {
  return items.map(item => ({
    ...item,
    id: nextId++,
  }))
}

export const categories: CategoryConfig[] = [
  {
    key: '1',
    label: '基础组件',
    items: addIdsToItems([
      { icon: SearchOutlined, text: '搜索框', type: 'search' },
      { icon: BellOutlined, text: '公告栏', type: 'notice' },
      // { icon: AppstoreOutlined, text: '菜单导航', type: 'menu' },
      // { icon: SearchOutlined, text: '宫格导航', type: 'grid' },
      // { icon: UnorderedListOutlined, text: '列表导航', type: 'list' },
      // { icon: BlockOutlined, text: '弹窗广告', type: 'popup' },
      // { icon: AppstoreAddOutlined, text: '悬浮按钮', type: 'float-button' },
    ]),
  },
  {
    key: '2',
    label: '图文组件',
    items: addIdsToItems([
      { icon: PictureOutlined, text: '单图展示', type: 'image' },
      { icon: CameraOutlined, text: '轮播图', type: 'carousel' },
      { icon: VideoCameraOutlined, text: '视频组件', type: 'video' },
      { icon: FontSizeOutlined, text: '标题文本', type: 'title' },
      { icon: BgColorsOutlined, text: '背景图', type: 'background' },
      { icon: LayoutOutlined, text: '图文混排', type: 'richtext' },
    ]),
  },
  {
    key: '3',
    label: '营销组件',
    items: addIdsToItems([
      { icon: TagOutlined, text: '优惠券', type: 'coupon' },
      { icon: StarOutlined, text: '积分商城', type: 'points' },
      { icon: FireOutlined, text: '秒杀专区', type: 'seckill' },
      { icon: ShoppingCartOutlined, text: '拼团商品', type: 'group-buy' },
      { icon: BellOutlined, text: '限时折扣', type: 'discount' },
    ]),
  },
  {
    key: '4',
    label: '用户组件',
    items: addIdsToItems([
      { icon: SearchOutlined, text: '用户中心', type: 'user-center' },
      { icon: AppstoreOutlined, text: '订单列表', type: 'order-list' },
      { icon: UnorderedListOutlined, text: '收货地址', type: 'address' },
      { icon: BellOutlined, text: '消息中心', type: 'message' },
      { icon: StarOutlined, text: '我的收藏', type: 'favorite' },
    ]),
  },
]
